/**
 * @Author：ming
 * @Date：2023/10/29 12:40 PM
 * @Filename：Hot3
 */

import java.util.ArrayList;

/**
 * @author ming
 */
public class Hot3 {
    public int lengthOfLongestSubstring(String s) {
       int len = s.length();
       int max =0;
        ArrayList<Character> list = new ArrayList<>();
        for (int i = 0; i < len; i++) {
            if(list.contains(s.charAt(i))){
                int index = list.indexOf(s.charAt(i));
                for (int j = 0; j <= index; j++) {
                    list.remove(0);
                }

            }
            list.add(s.charAt(i));
            max = Math.max(max,list.size());
        }

        return max;
    }
}
